<template>
  <div class="main">
    <van-nav-bar
      :title="title"
      left-text="返回"
      left-arrow
      @click-left="clickleft"
      fixed
    />
    <router-view></router-view>
    <van-tabbar
      v-model="active"
      active-color="orange"
      inactive-color="red"
    >
      <van-tabbar-item
        icon="home-o"
        to="/home"
      >主页</van-tabbar-item>
      <van-tabbar-item
        icon="friends-o"
        to="/personal"
      >个人中心</van-tabbar-item>
      <van-tabbar-item
        icon="cart-o"
        to="/shopCar"
        :badge=$store.getters.getallGoods
      >购物车</van-tabbar-item>
      <van-tabbar-item
        icon="search"
        to="/search"
      >搜索</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data: () => ({
    title: sessionStorage.title || 'home',
    active: Number(sessionStorage.active) || 0
  }),
  methods: {
    clickleft() {
      this.$router.go(-1)
    }
  },
  watch: {
    '$route.meta'(meta) {
      this.title = meta.title123
      this.active = meta.active
      sessionStorage.title = meta.title
      sessionStorage.active = meta.active
      // test
    }
  }
}

</script>
<style lang="less" >
.main {
  padding-top: 46px;
  padding-bottom: 50px;
  .van-nav-bar__title {
    font-family: "楷体";
    font-size: 25px;
    color: skyblue;
  }
  .van-nav-bar__text {
    font-family: "楷体";
    font-size: 20px;
  }
  .van-tabbar-item__text {
    font-family: "楷体";
    color: hotpink;
    font-size: 16px;
    text-align: center;
  }
}
</style>
